import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

/**
 * class for error message
 */
public class ErrWin extends JFrame {

	
	private JPanel errPanel;
	/**
	 *  label for the error
	 */
	private JLabel lblError;
	/**
	 *   lable for the msg
	 */
	private JLabel lblMsg;
	private String msg;
	
	public ErrWin (String s){
		msg = s;
		initialize();
	}
	
	private void initialize() {
		
		this.setLocation(430, 200);
		this.setSize(342, 187);
		errPanel = new JPanel();
		getContentPane().add(errPanel);
		errPanel.setLayout(null);
		errPanel.add(getOK());
		
		errPanel.add(getOK());
		
		lblError = new JLabel("Error");
		lblError.setBounds(147, 11, 46, 14);
		errPanel.add(lblError);
		
		lblMsg = new JLabel(msg);
		lblMsg.setHorizontalAlignment(SwingConstants.CENTER);
		lblMsg.setBounds(-15, 55, 357, 14);
		errPanel.add(lblMsg);
		this.setTitle("Academic Managment Tool");
		this.setVisible(true);
	}	
	
	/**
	 * 
	 * @return
	 */
	private JButton getOK()
	{
		JButton btnOKButton = new JButton("OK");
		btnOKButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		btnOKButton.setBounds(120, 115, 89, 23);
		return btnOKButton;
	}
	
}
